package com.example.springhelloworld.controller;

import com.example.springhelloworld.model.VO.DoVO;
import com.example.springhelloworld.services.DoDaoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/do")
public class DoDaoController {

    @Autowired
    private DoDaoService doDaoService;

    @ResponseBody
    @RequestMapping("/query")
    public Map<String, Object> queryDo(int min, int max) {
        List<DoVO> dos = doDaoService.querySo(min, max);
        for (DoVO aDo : dos) {
            System.out.println(aDo);
        }
        Map<String, Object> map = new HashMap<>();
        map.put("msg", 200);
        return map;
    }

    @ResponseBody
    @RequestMapping("/queryLikeName")
    public Map<String, Object> queryLikeName(int min) {
        List<DoVO> dos = doDaoService.queryLikeName(min);
        for (DoVO aDo : dos) {
            System.out.println(aDo);
        }
        Map<String, Object> map = new HashMap<>();
        map.put("msg", 200);
        return map;
    }

    @ResponseBody
    @RequestMapping("/queryTime")
    public Map<String, Object> queryTime() {
        List<DoVO> dos = doDaoService.queryTime();
        for (DoVO aDo : dos) {
            System.out.println(aDo);
        }
        Map<String, Object> map = new HashMap<>();
        map.put("msg", 200);
        return map;
    }

    @ResponseBody
    @GetMapping("/insertGood")
    public Map<String, Object> insertGood(String str1, String str2) {
        int i = doDaoService.insertGood(str1, str2);
        Map<String, Object> map = new HashMap<>();
        map.put("msg", 200);
        map.put("data", i);
        return map;
    }
}
